﻿using System.Collections.Generic ;

namespace OpenLightGroup.Common.UserManagement.Web
    {
        using System.ComponentModel.DataAnnotations ;
        using System.Runtime.Serialization ;
 
        /// <summary>
        /// Class containing the values and validation rules for user registration.
        /// </summary>
        /// 
        [KnownType( typeof(UserRegistration) )]
        public  partial class User
            {
                /// <summary>
                /// Gets and sets the user name.
                /// </summary>
                [Key]
                [Required( ErrorMessage = "Username is required" )]
                [Display( Order = 0, Name = "Username" )]
                [RegularExpression( "^[a-zA-Z0-9_]*$", ErrorMessage = "Invalid user name. It must contain only alphanumeric characters" )]
                [StringLength( 255, MinimumLength = 4, ErrorMessage = "The user name must be at least 4 and at most 255 characters long" )]
                [Editable( true )]
                public string UserName { get ; set ; }

                /// <summary>
                /// Gets and sets the email address.
                /// </summary>
                [Key]
                [Required( ErrorMessage = "Email is required" )]
                [Display( Order = 2, Name = "Email" )]
                [RegularExpression( @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
                                   ErrorMessage = "Invalid email. An email must use the format user@company.com" )]
                [Editable( true )]
                public string Email { get ; set ; }

                public IEnumerable<string> Roles { get ; set ; }

                public bool Enabled { get ; set ; }

            }
    }